<template>
	<view class="page">
		<!-- <view>我的</view> -->
		<view class="head">
			<view class="head-item">
				<view class="head-portrait" @click="gotoPage('/pagesUser/user/update_portrait/update_portrait')">
					<image v-if="userinfo.avatarUrl == ''" src="../../../static/dafaulthead2.png"></image>
					<image :src="userinfo.avatarUrl" mode="" v-else></image>
				</view>
				<view class="head-info" v-if="att_info == null" @click="gotoPage('/register/approve/approve')">
					<view class="head-info-name">{{userinfo.nickName}}</view>
					<view class="head-info-att head-info-attNot" >
						<!-- <image src="../../../static/user/per-icon2.png"></image> -->
						<text>未认证</text>
					</view>
				</view>
				<view class="head-info" v-else @click="gotoApprove">
					<view class="head-info-name">{{userinfo.nickName}}</view>
					<view class="head-info-att" v-if="att_info.types == 1">
						<image src="../../../static/user/per-icon2.png"></image>
						<text>个人认证</text>
					</view>
					<view class="head-info-att" v-if="att_info.types == 2">
						<image src="../../../static/user/firm-icon.png"></image>
						<text>企业认证</text>
					</view>
					<view class="head-info-att" v-if="att_info.types == 3">
						<image src="../../../static/user/ju-icon.png"></image>
						<text>旅行社认证</text>
					</view>
				</view>
			</view>
		</view>
		<view class="item-nav">
			<view class="item-nav-name">
				<view class="item-nav-bank" @click="gotoPage('/pagesUser/user/my-wallet/my-wallet')">
					<image src="../../../static/user/wallet-icon.png"></image>
					<text>我的钱包</text>
				</view>
				<view class="item-nav-bank" @click="gotoPage('/pagesUser/user/back-manage/back-manage')">
					<image src="../../../static/user/back-icon.png"></image>
					<text>我的银行卡</text>
				</view>
			</view>
		</view>

		<view class="item-box">
			<view class="item-box-con" @click="gotoPage('/pagesUser/user/invite/invite')">
				<view class="set">
					<image src="../../../static/user/invo-icon.png"></image>
					<view>邀请好友</view>
				</view>
				<image class="set-next" src="../../../static/jiantou3.png"></image>
			</view>
			<view class="item-box-con" @click="gotoPage('/pagesUser/user/idea/idea')">
				<view class="set">
					<image src="../../../static/user/idea-icon.png"></image>
					<view>意见反馈</view>
				</view>
				<image class="set-next" src="../../../static/jiantou3.png"></image>
			</view>
			<view class="item-box-con" @click="gotoPage('/pagesUser/information/service-info/service-info')">
				<view class="set">
					<image src="../../../static/user/service-icon.png"></image>
					<view>客服中心</view>
				</view>
				<image class="set-next" src="../../../static/jiantou3.png"></image>
			</view>
			<view class="item-box-con" @click="gotoPage('/pagesUser/user/aboutUs/aboutUs')">
				<view class="set">
					<image src="../../../static/user/about-icon.png"></image>
					<view>关于我们</view>
				</view>
				<image class="set-next" src="../../../static/jiantou3.png"></image>
			</view>
			<view class="item-box-con" @click="gotoApprove()">
				<view class="set">
					<image src="../../../static/user/myAtt-icon.png"></image>
					<view>我的认证</view>
				</view>
				<image class="set-next" src="../../../static/jiantou3.png"></image>
			</view>
			<view class="item-box-con" @click="gotoPage('/pagesUser/user/set/set')">
				<view class="set">
					<image src="../../../static/user/set.png"></image>
					<view>设置</view>
				</view>
				<image class="set-next" src="../../../static/jiantou3.png"></image>
			</view>
		</view>
		<view style="height: 120rpx;"></view>
		<!-- <footUser></footUser> -->
		<footTabber></footTabber>
	</view>
</template>

<script>
	// /import footUser from '@/components/tabbar/footUser.vue'
	export default {
		// components: {
		// 	footUser
		// },
		data() {
			return {
				att_info: '', //认证
				userinfo: '', //
			};
		},
		onShow() {
			this.getAttInfo();
			this.getData();
		},
		onPullDownRefresh() {
			this.getData();
			this.getAttInfo();
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			/* 认证 */
			gotoApprove() {
				let self = this;
				console.log(self.att_info)
				if (self.att_info == null) {
					uni.navigateTo({
						url: '/register/approve/approve'
					})
					// uni.showModal({
					// 	title: '您还未认证，请前去认证。',
					// 	success: (res) => {
					// 		if (res.confirm) {
					// 			uni.navigateTo({
					// 				url: '/register/approve/approve'
					// 			})
					// 		} else if (res.cancel) {
					// 			return;
					// 			//console.log('quexiao')
					// 		}
					// 	}
					// })
				} else if (self.att_info != null) {
					if (self.att_info.types == 1) {
						uni.navigateTo({
							url: '/register/approve-person/approve-person?select=1&&type=1'
						})
					} else if (self.att_info.types == 2) {
						uni.navigateTo({
							url: '/register/approve-firm/approve-firm?select=1&&type=2'
						})
					} else if (self.att_info.types == 3) {
						uni.navigateTo({
							url: '/register/approve-travel/approve-travel?select=1&&type=3'
						})
					}
				}
			},
			/* 获取个人数据 */
			getData() {
				let self = this;
				uni.showLoading({
					title: '加载中'
				});
				self._get('user.index/setting', {}, function(res) {
					self.userinfo = res.data.userInfo;
					self.loadding = false;
					uni.hideLoading();
				});
			},
			/* 获取用户认证接口 */
			getAttInfo() {
				let self = this;
				uni.showLoading({
					title: '加载中'
				});
				self._post('user.user/attestation_info', {}, function(res) {
					//console.log(res.data.info)
					self.att_info = res.data.info;
					uni.hideLoading();
				});
			},
			/*跳转页面*/
			gotoPage(path) {
				let self = this;
				if (path.startsWith('/')) {
					uni.navigateTo({
						url: path
					});
				} else {
					self[path]();
				}
			},
		}
	}
</script>

<style lang="scss">
	@import 'index.scss';

	.item-box {
		margin-top: 30rpx;
	}
</style>
